﻿using Microsoft.Xna.Framework;
using GlobalGameClasses;

namespace DrawableObjects.Actors.Projectiles
{
    public class SonarWave : Projectile
    {
        /// <summary>
        /// this class creates the weaponsystem "sonarwave"
        /// creates the sonar wave of the boss aswell
        /// </summary>
        private SonarWave(float speed, int baseDamage, string strTextureModel, Matrix worldMatrix, float scaleFactor, float boundingFactor, string explosionSound)
            : base(speed, baseDamage, strTextureModel, worldMatrix, scaleFactor, boundingFactor, explosionSound)
        {
            this.strTextureModel = strTextureModel;
        }


        public static SonarWave GET_SONARWAVE_BOSS()
        {
            SonarWave wave = new SonarWave(0.0f, 1000000, "ring", Matrix.CreateWorld(new Vector3(0, GlobalGameValues.GAMEFIELD_HEIGHT, 0), Vector3.Backward, Vector3.Up), 1, 1, "missileExplosion");
            wave.actorAttributes.Add(ActorAttributes.Floating);
            wave.actorAttributes.Add(ActorAttributes.Unremoveable);
            return wave;
        }


        public override void Update()
        {
            this.scaleFactor += 0.05f;
            this.boundingSphereFactor += 0.5f;
            Vector3 trans = worldMatrix.Translation + Vector3.Multiply(worldMatrix.Forward, this.speed);
            worldMatrix = Matrix.CreateScale(scaleFactor) * Matrix.CreateWorld(trans, worldMatrix.Forward, Vector3.Up);
            this.boundingSphere = new BoundingSphere(worldMatrix.Translation, boundingSphereFactor);

        }

        public override Projectile Clone(Vector2 position, Vector2 direction)
        {
            Matrix newMatrix = this.worldMatrix;
            newMatrix.M41 = position.X;
            newMatrix.M43 = position.Y;
            SonarWave cloned = new SonarWave(this.speed, this.baseDamage, this.strTextureModel, newMatrix, this.scaleFactor, this.boundingSphereFactor, this.explosionSound);
            cloned.actorAttributes = this.actorAttributes;
            cloned.direction = direction;
            cloned.standardRotation = this.standardRotation;
            return cloned;
        }

        public override void collide(Actor actor2)
        {
            //do nothing
        }

    }
}

